import requests
import json
import sys
if sys.version_info < (3, 0):
    from urlparse import urljoin  # noqa
else:
    from urllib.parse import urljoin  # noqa
    from urllib.parse import urlencode


class GithubLogin:

    BASE_URL = "https://github.com"

    @classmethod
    def post_acctoken(cls, clientid, clientsec, usr, pwd):
        params_dic = {
            "client_id": clientid,
            "scopes": "user:email",
            "note": "user:email",
            "client_secret": clientsec

        }
        params = urlencode(params_dic)
        furl = urljoin(cls.BASE_URL, "/login/oauth/authorize?%s") % params
        print(furl, '_>>>>furl')
        ret = requests.post(furl)
        print(ret, '_->>>ret')


if __name__ == "__main__":
    GithubLogin.post_acctoken("e97e0cbaac10a85c1b30",
                              "408ad2450d67ca82ae46be0ea2ded84f75caf05c", "dwb@dwb.ren", "aA.76366151")
